package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsGlobalId;
import com.econ.powercloud.ems.dal.mapper.EmsGlobalIdMapper;
import org.springframework.stereotype.Repository;

/**
 * @Author : zjf
 * @Description : ems生成全局唯一自增id DAO
 * @Date : 2021/8/19 9:55
 * @Modified by : zjf
 */
@Repository
public class EmsGlobalIdDAO extends ServiceImpl<EmsGlobalIdMapper, EmsGlobalId> {

    /**
     * 获取唯一全局id
     */
    public Integer getGlobalId(){
        EmsGlobalId emsGlobalId = EmsGlobalId.builder().gmtCreate(System.currentTimeMillis()).build();
        this.baseMapper.insert(emsGlobalId);
        return emsGlobalId.getId();
    }
}
